cmake_minimum_required(VERSION 3.25)
set(MATLAB_DIRS "C:/Program1/MATLAB/R2022b")
set(LIB_NAME "libname") # 生成的dll文件的名字
set(FUNC_LIB "myFFT2") # matlab导出的lib文件名称，可以填多个，空格隔开

link_directories(./)

add_library(${LIB_NAME} SHARED export.cpp)
target_compile_definitions(${LIB_NAME} PRIVATE -DINTERFACE_EXPORTS)
target_link_libraries(${LIB_NAME} PRIVATE ${FUNC_LIB})

# Opencv
find_package(OpenCV REQUIRED)
target_include_directories(${LIB_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${LIB_NAME} PRIVATE ${OpenCV_LIBS})
# Opencv

# Matlab
set(MATLAB_LIB "libmat.lib libmex.lib mclmcr.lib mclmcrrt.lib mclbase.lib")
set(MATLAB_INCLUDE_DIRS "${MATLAB_DIRS}/extern/include")
set(MATLAB_LINK_DIRS "${MATLAB_DIRS}/extern/lib/win64/microsoft")
target_link_directories(${LIB_NAME} PRIVATE ${MATLAB_LINK_DIRS})
target_link_libraries(${LIB_NAME} PRIVATE ${MATLAB_LIB})
target_include_directories(${LIB_NAME} PRIVATE ${MATLAB_INCLUDE_DIRS})
# Matlab end
